Skip to content

New and ported response concepts for companion NPCs#271

Merged
Blixibon merged 7 commits into
mapbase-source:developfrom
Blixibon:mapbase/feature/new-companion-npc-concepts
Feb 4, 2024
Merged

New and ported response concepts for companion NPCs#271
Blixibon merged 7 commits into
mapbase-source:developfrom
Blixibon:mapbase/feature/new-companion-npc-concepts

Conversation

@Blixibon
Copy link
Copy Markdown
Member

@Blixibon Blixibon commented Jan 3, 2024

This PR integrates new response concepts intended for custom companion NPCs, including citizens and other NPCs descending from CNPC_PlayerCompanion. Many of these concepts were ported from Alyx's EP1/EP2 code, but a few of them are completely new.

Here's a list of concepts ported from Alyx:

  • TLK_ENEMY_BURNING — Spoken when the NPC's enemy is ignited.
  • TLK_DANGER_ZOMBINE_GRENADE — Spoken when a zombine pulls out a grenade.
  • TLK_SPOTTED_INCOMING_HEADCRAB — Spoken when an enemy headcrab is seen for the first time while it's already mid-jump.
  • TLK_SPOTTED_HEADCRAB_LEAVING_ZOMBIE — Spoken when a headcrab is seen leaving a zombie that just died.
  • TLK_SPOTTED_ZOMBIE_WAKEUP — Spoken when a zombie is seen emerging from a slump actbusy.

Alyx is still fully capable of using these concepts.

Here's a list of completely new concepts:

  • TLK_TAKING_FIRE — Spoken when someone fires at me, regardless of whether I was hit. (requires ai_shot_notify_targets to be enabled)
  • TLK_NEW_ENEMY — Spoken when a new enemy appears. Unlike TLK_STARTCOMBAT, this can be spoken during combat and has no delay between combat engagements. This is intended to be used when a new enemy enters an already-active arena.
  • TLK_COMBAT_IDLE — Randomly spoken when in combat, but not currently attacking (e.g. in cover or reloading). Similar to TLK_ATTACKING, but for when in an intermittent combat state.

TLK_TAKING_FIRE uses a new function called OnEnemyRangeAttackedMe which any class descended from CBaseCombatCharacter can use. It's triggered by CBaseEntity::FireBullets() every time it runs. NPCs trigger OnEnemyRangeAttackedMe on their current enemy. Players use a separate function called GetProbableAimTarget to try to determine what the player is most likely aiming at.

This functionality is enabled by a cvar called ai_shot_notify_targets, which is disabled by default. This can be enabled on a mod-by-mod (or map-by-map using game_convar_mod) basis when TLK_TAKING_FIRE is used, or for when the function is used for some other purpose (such as custom AI).

Note that this does not currently account for func_tanks or any other bullets fired by "indirect" entities. It also does not account for non-bullet range attacks.


This PR also adds support for additional enemy and func_tank criteria.


PR Checklist

  • My PR follows all guidelines in the CONTRIBUTING.md file
  • My PR targets a develop branch OR targets another branch with a specific goal in mind

Copy link
Copy Markdown

@1upD 1upD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Blixibon Blixibon merged commit 4c2823e into mapbase-source:develop Feb 4, 2024
@Blixibon Blixibon deleted the mapbase/feature/new-companion-npc-concepts branch February 4, 2024 21:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants